package com.aidex.biz.uitls;

import com.aidex.common.utils.http.HttpUtils;
import com.alibaba.fastjson.JSONObject;

public class TargetLinkUitls {
    private static final String appId = "6cb43b8b608345299e79a4e1c509c0b4";
    private static final String appSecret = "6LPM43Qh6PIWmYcre+Lj4Sc49/ApcY1OKUVUAwQk5qc=";
    private static final String publicKey =
            "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3fRcHHhvaurTmHQmg9ydoNSsQHBlf0WkouLa4JiEp1Qnyxd0nzeLOEMB4BVXKk2qeJf4ob7Exrc1dKC7HSz+YA4YrdXfQb9uwDzRe6eR5AW3hC1MvRLvRqASJf9mGYaaFCqPtarlE1KYlcAsJ9OICX4TNiGGsrJuW0fBIinI1iwIDAQAB";

    public static String getTargetLink(String phone) {
        String url = null;
        try {
            String targetLink = "https://ctapp.ycchantou.com/ycct/api/third/getTargetLink";
            String app_secret = APISecureUtil.encodeRSA(appSecret, publicKey);
            JSONObject param = new JSONObject();
            param.put("app_id", appId);
            param.put("app_secret", app_secret);
            param.put("mobile", phone);
            String result = HttpUtils.doPost(targetLink, param);
            JSONObject jsonObject = JSONObject.parseObject(result);
            if (null != jsonObject) {
                url = APISecureUtil.decryptRSA(jsonObject.getString("data"), publicKey);
            }
        } catch (Exception e) {
            return null;
        }
        return url;
    }

    public static void main(String[] args) {
        System.out.println(getTargetLink("15997686502"));
    }
}
